<?php
/**
 * 问律师
 * @author Wesley
 *
 */
class PostController extends BaseAdminController {
	public function index()
	{
		$posts = Post::where('type', Post::TYPE_QUESTION )->paginate(Config::get('app.page_row'));
		$cateList = UtilsHelper::workScopeKeyValue();
		$this->layout->content = View::make('admin.post.index')->with( compact('posts', 'cateList'));
	}
	public function removeComment($post_id, $comment_id)
	{
		Comment::find($comment_id)->softDelete();
		return Redirect::back();
	}
	
	public function remove($id)
	{
		Post::find($id)->delete();
		return Redirect::back();
	}
	
	public function detail($id)
	{
		$post = Post::find($id);
		$comments = Comment::where('post_id',$id)->get();
		$this->layout->content = View::make('admin.post.detail')->with( compact('post','comments'));
	}
	
	public function setrecommend($id)
	{
		$post = Post::where('id', $id)->firstOrFail();
		$post->is_recommend = abs($post->is_recommend -1);
		$post->save();
		return Redirect::back();
	}
	public function settop($id)
	{
		$post = Post::where('id', $id)->firstOrFail();
		$post->is_top = abs($post->is_top -1);
		$post->save();
		return Redirect::back();
	}
}